package com.airport.schedule.util;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;

public class ListUtil {

    public static<T> List<T> filter(List<T> ls, Predicate<T> predicate) {
        List<T> nls = new ArrayList<>();
        for(T e : ls) {
            if(predicate.test(e)) {
                nls.add(e);
            }
        }
        return nls;
    }

    public static <T, R> List<R> map(List<T> ls, Function<T, R> mapFunc) {
        List<R> nls = new ArrayList<>();
        for(T e : ls) {
            nls.add(mapFunc.apply(e));
        }
        return nls;
    }

}
